<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>

<html>
	<head>
		<title>My JSP 'addPackformStyle.jsp' starting page</title>
	</head>
	<body>
	<section class="content">
<div class="row">
		<div class="col-md-12">

			<!-- Primary box -->
			<div class="box box-solid box-primary">
				<div class="box-header">
					<i class="fa fa-edit"></i>
					<h3 class="box-title">${titlePage}</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<div class="box-body">
				<div class="form-group row">
		<div id="message" class="alert alert-success" style="display: none;">
			<button data-dismiss="alert" class="close">
				×
			</button>
		</div>
		<div class="col-sm-6">
			<div class="input-group col-sm-12">
				<label for="pmsprinters_corpLevel" class="input-group-text">
					随箱单名称:
				</label>
				<div class="col-sm-6">
					<input type="text" id="styleName" name="styleName" value=""
						class="form-control input-large required" minlength="3" />
				</div>
			</div>
			</div>
			
			<div class="col-sm-6">
			<div class="input-group col-sm-12">
				<label for="pmsprinters_corpLevel" class="input-group-text">
				<!-- 原来的随箱单样式去掉（没用）,暂时把这个字段用于判断是否显示库位 -->
					是否带库位:
				</label>
				<div class="col-sm-6">
					<input type="radio" id="type" name="type" value="A4" >是<span style="margin-left: 10px;"> </span>
					<input type="radio" id="type" name="type" value="A5" checked="checked" onchange="changeType(this)">否
				</div>
			</div>
			</div>

</div>
				</div>
				</div>
				</div>
				</div>
			<script type="text/javascript">
 var tempString="";
 var index=0;
 var tempIndex=0;
 var packformType=0;
 var type="";
 
 $(function(){
	 $("input[name=type]").unbind();
	 $("input[name=type]").bind("click",function(){
		 alert("111");
		 type=$("input[name=type]:checked").val();
	 });
	 $("input[name=type]").click(function(){
		 type=$("input[name=type]:checked").val();
	 });
 });      
  function changeType(item){
    type=item.value;
  }
 	function messageShow(temp){
		$("#message").html("<button data-dismiss=\"alert\" class=\"close\">×</button>"+temp);
		    $("#message").show();
                   $(function () {
                       setTimeout(function () {
                            $("#message").hide();
                       }, 6000);
                  });
		}
 function addAjaxPackformStyle(tableContent) {
	 type=$("input[name=type]:checked").val();	
	 $.ajax({
			    type : 'post',
                url : '${ctx}/v2/packformStyle/addAjaxPackformStyle',
			    data :  'content=' + tableContent+'&customerCode=${customers.customerCode}&styleName='+ $("#styleName").val()+'&type='+type,
			    dataType : 'json',
				success : function(data) {
						if (data.status == "1") {
						  $("#submit_btn").attr("disabled", "disabled");
						
							messageShow("增加成功");
						} else {
							messageShow("增加失败");
						}
					},
					error : function() {
						messageShow("增加失败");
					}
				});
	}
	
	
 
	  function validate(width,height){
       var reg = new RegExp("^[0-9]*$");
    if(!reg.test(width)||!reg.test(height)){
        alert("请输入数字!");
        return false;
    }
    if(!/^[0-9]*$/.test(width)||!/^[0-9]*$/.test(height)){
        alert("请输入数字!");
        return false;
    }
    return true;
  }
	 
	function preview() {
		var width = $("#widthDiv").val();
		var height = $("#widthDiv").val();
		if(width==""||width==null){
		     width=1000;
		}
		if(height==""||height==null){
		     height=400;
		 }
		if(!validate(width,height)){
	      return;
	    }
		LODOP = getLodop(document.getElementById('LODOP_OB'), document
				.getElementById('LODOP_EM'));
		LODOP.ADD_PRINT_HTM(0, 0, ""+width+"", ""+height+"", document
				.getElementById("textarea").innerHTML);
		LODOP.PREVIEW();
		//LODOP.PRINT_DESIGN();
	}
	
	
	


function addStyle(){
  var stringTable=$("#styleContent").val();
 
  addAjaxPackformStyle(encodeURI(stringTable));
}

</script>
<div class="row">
		<div class="col-md-12">

			<!-- Primary box -->
			<div class="box box-primary">
				<div class="box-body">
					<div class="row">
						<div class="col-sm-12">
							<textarea class="form-control" rows="20" cols="20" id="styleContent"></textarea>
						</div>
					</div>
			
			<div class="modal-footer bg-gray">

					<input id="submit_btn" class="btn btn-primary" type="button"
						value="增加" onclick="addStyle()" />
					
					<input id="cancel_btn" class="btn btn-default" type="button" value="返回"
						onclick="history.back()" />
				</div>
				</div>
				</div>
				</div>
				</div>
				</section>
	</body>
</html>
